/**
 * TimerJobDaoImpl.java
 * Created at 2017-09-14
 * Created by Jackie liu
 * Copyright (C) 2014, All rights reserved.
 */
package com.huabo.dao.impl.oracle;

import com.huabo.base.BaseDaoImpl;
import com.huabo.dao.inter.TimerJobDao;
import com.huabo.model.TimerJob;
import com.huabo.sql.builder.WhereBuilder;
import com.huabo.utils.Page;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * <p>ClassName: TimerJobDaoImpl</p>
 * <p>Description: 定时器任务Dao实现</p>
 * <p>Author: Jackie liu</p>
 * <p>Date: 2017-09-14</p>
 */
@Repository
public class TimerJobDaoImpl extends BaseDaoImpl<TimerJob, Long> implements TimerJobDao {

    @Override
    public boolean isDuplicateName(Long id, String name) {
        return isDuplicateField(id, name, "F_NAME");
    }

    @Override
    public boolean isDuplicateClassAndMethodName(Long id, String className, String methodName) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("F_CLASS_NAME", className);
        wb.andEquals("F_METHOD_NAME", methodName);
        wb.andNotEquals("F_ID", id);
        return count(wb) > 0;
    }

    @Override
    public Page<TimerJob> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
            wb.andFullLike("F_NAME", params.get("name"));
        }
        return queryPage(wb);
    }
}